const Tag = require('../../models/tag')

module.exports = (req, res) => {
  const tag_id = '62162ed14c4270244c5f60db'
  Tag.findById({
    _id: tag_id
  }, (err, tagDoc) => {
    if (err) {
      res.status(500).json({
        err_code: 500,
        message: err.message
      })
    }
    // 热门标签
    var hotTags = []
    var max = 3
    for (let i = 0; i < tagDoc.tags.length; i++) {
      const element = tagDoc.tags[i]
      temp = element.tag_number
      if (temp >= max) {
        hotTags.push(element)
      }
    }
    // console.log(hotTags);
    res.status(200).json({
      err_code: 0,
      data: hotTags,
      tagDoc,
      message: '查询成功'
    })
  })
}